package day0927;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

class Book{ int pageSize;}//1.
class BComparator implements Comparator<Book>{
    public int compare(Book o1, Book o2) {
        return o1.pageSize - o2.pageSize;//升序： o1的值  -  o2的值
    }
}
public class S3 {
    public static void main(String[] args) {
        ArrayList<Book> list=new ArrayList<>();
        Book java=new Book(); java.pageSize=500;    list.add(java);
        Book linux=new Book(); linux.pageSize=497;  list.add(linux);
        Collections.sort(list, new BComparator());
        for(Book b:list){
            System.out.println("b.pageSize = " + b.pageSize);
        }
    }
}


